let express = require('express');
let router = express.Router();

const censusService = require('../service/censusService');

const checkJWTMiddleWare = require('../middleWare/checkJWTMiddleWare');

// 此路由需要登录后才能访问
router.use(checkJWTMiddleWare);

// /*
//  * 导入普查记录接口
//  */
// router.post('/importCensus', async function (req, res, next) {});

// /*
//  * 查询某个学生的所有普查记录接口
//  */
// router.get('/getCensusRecordByStudent', async function (req, res, next) {});

/*
 * 查询某个学生的所有测评记录
 */
router.post('/getAssessRecordsByStudentId', async function (req, res, next) {
    let studentId = req.body.studentId;
    if (!studentId) {
        res.status(400).json({ success: false, msg: '参数错误' });
        return ;
    }
    let result = await censusService.getAssessRecordsByStudentId(req.jwtResult.data.uid, req.jwtResult.data.userType, studentId);
    res.status(result.success ? 200 : 400).json(result);
});

module.exports = router;